package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理" ,tags = "这是频道管理", description = "频道管理API")
public class AdChannelController implements AdChannelControllerApi {
    @Autowired
    private AdChannelService channelService;


    @PostMapping("/list")
    @ApiOperation(value = "查询频道信息",notes = "根据名称分页查询频道列表")
    @ApiImplicitParam(name = "ChannelDto",type ="dto",value = "查询名称")
    @Override
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto){
        return channelService.findByNameAndPage(dto);
    }


    @PostMapping("/save")
    @ApiOperation(value = "添加频道",notes = "添加频道")
    @ApiImplicitParam(name = "channel",type ="channel",value = "添加频道")
    @Override
    public ResponseResult insert(@RequestBody AdChannel channel) {
        return channelService.insert(channel);
    }


    @PostMapping("/update")
    @ApiOperation(value = "修改频道",notes = "修改频道")
    @ApiImplicitParam(name = "channel",type ="adChannel",value = "修改频道")
    @Override
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return channelService.update(adChannel);
    }


    @DeleteMapping("/delete")
    @ApiOperation(value = "删除频道",notes = "删除频道")
    @ApiImplicitParam(name = "Integer",type ="id",value = "删除频道")
    @Override
    public ResponseResult deleteById(Integer id) {
        return channelService.deleteById(id);
    }


}
